package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.pojo.Permission;
import com.itheima.service.PermissionService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PermissionController {

    @Reference
    private PermissionService permissionService;

    // /permission/findPage 分页查询
    @RequestMapping("/permission/findPage")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean){
        return permissionService.findPage(queryPageBean);
    }

    // /permission/add 新增
    @RequestMapping("/permission/add")
    public Result add(@RequestBody Permission permission){
        return permissionService.add(permission);
    }

    // /permission/findById 查询某一个权限的详细信息
    @RequestMapping("/permission/findById")
    public Result findById(Integer id){
        return permissionService.findById(id);
    }

    // /permission/edit   修改权限信息
    @RequestMapping("/permission/edit")
    public Result edit(@RequestBody Permission permission){
        return permissionService.updatePermission(permission);
    }

    // /permission/delete  删除某一个权限
    @RequestMapping("/permission/delete")
    public Result delete(Integer id){
        return permissionService.deletePermission(id);
    }
}
